package com.quick.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.quick.base.Page;
import com.quick.base.Search;
import com.quick.basic.pojo.BaseBanner;
import com.quick.basic.search.BannerSearch;
import com.quick.basic.vo.BannerVo;
import com.quick.mapper.BannerMapper;
import com.quick.service.IBannerService;
import com.quick.util.PageUtil;
@Service
public class BannerServiceImpl implements IBannerService {
	
	@Autowired
	private BannerMapper bannerMapper;

	@Override
	public Page<BannerVo> search(Search<BannerSearch> search) {
		PageHelper.startPage(search.getPageNum(), search.getPageSize());
		QueryWrapper<BaseBanner> queryWrapper = new QueryWrapper<BaseBanner>();
		queryWrapper.lambda().eq(BaseBanner::getStatus, "01");
		queryWrapper.lambda().eq(BaseBanner::getSite,search.getSearch().getSite());
		List<BaseBanner> banners = bannerMapper.selectList(queryWrapper);
		PageInfo<BaseBanner> pageInfo = new PageInfo<BaseBanner>(banners);
		return PageUtil.page(pageInfo, BannerVo.class);
	}

}
